# -*- coding: utf-8 -*-
# @Author  : pony.guan
# @Time    : 2022/5/26 11:28
# Description:
import json
from kafka import KafkaProducer

bootstrap_servers = ['172.20.8.146:9092', ]
producer = KafkaProducer(
    bootstrap_servers=bootstrap_servers,
    value_serializer=lambda m: json.dumps(m).encode())

message = {
    "msgBody": {
        "actionModel": 0,
        "bins": [
            {
                "binId": 11473,
                "locationId": 1001719
            },
            {
                "binId": 23983,
                "locationId": 1001735
            },
            {
                "binId": 29806,
                "locationId": 1001862
            }
        ]
    },
    "msgId": 0,  # 保证唯一数字
    "msgType": 9220
}

producer.send('ks_mission_control', message)
producer.flush()

# for data in datas:
#     producer.send(topic, data)
#     producer.flush()

"""
{
    "msgBody": {
        "actionModel": 0,
        "bins": [
            {
                "binId": 11473,
                "locationId": 1001719
            },
            {
                "binId": 23983,
                "locationId": 1001735
            },
            {
                "binId": 29806,
                "locationId": 1001862
            }
        ]
    },
    "msgId": 0,     # 保证唯一数字
    "msgType": 9220
}



"""
